package org.bird.jvm;

/**
 * @Described：垃圾回收逃逸分析
 * @VM args : -Xms5M -Xmx5M -Xmn3M -XX:PermSize=10M -XX:MaxPermSize=10M -XX:+PrintGCDetails
 * @author liangjf
 *
 */
public class FinalizedEscape {

	public static void main(String[] args) throws InterruptedException {
		System.out.println(FinalizedEscapeTestCase.caseForEscape);
		FinalizedEscapeTestCase.caseForEscape = new FinalizedEscapeTestCase();
		System.out.println(FinalizedEscapeTestCase.caseForEscape);
		FinalizedEscapeTestCase.caseForEscape = null;
		System.gc();
		Thread.sleep(100);
		System.out.println(FinalizedEscapeTestCase.caseForEscape);
	}

	static class FinalizedEscapeTestCase {

		public static FinalizedEscapeTestCase caseForEscape = null;

		@Override
		protected void finalize() throws Throwable {
			super.finalize();
			caseForEscape = this;
			System.out.println("哈哈，我已逃逸...");
		}
	}
}
